#from getStroke import genStrokes
import numpy as np
from config import Config
import os
import h5py
import matplotlib.pyplot as plt
import cv2

config = Config()
def MSE(image,gt):
      if len(image.shape)>2:
           image=image[:,:,0]
      if len(gt.shape)>2:
           gt=gt[:,:,0]
  
      width=image.shape[0]
      height=image.shape[1]
      sumup=0
      for j in range(width):
         for k in range(height):
             sumup=sumup+(image[j,k]-gt[j,k])*(image[j,k]-gt[j,k])
      MSE=sumup/(width*height)
      return MSE



gt=cv2.imread('/home/chen/Desktop/Comparing/GT/GT01.png')
gt=cv2.resize(gt,(config.img_sz,config.img_sz))

SharedMatte=cv2.imread('/home/chen/Desktop/Comparing/SharedMatting/GT01.png')
SharedMatte=cv2.resize(SharedMatte,(config.img_sz,config.img_sz))

matte=cv2.imread('/home/chen/Desktop/RNN_Matting/test_stage/first_try_DATA/tmp/matte.png')
matte=cv2.resize(matte,(config.img_sz,config.img_sz))

print MSE(matte,gt)
print MSE(SharedMatte,gt)
